package com.ricchieri.service;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Transactional;

import com.ricchieri.dao.interf.IReservationTypeDao;
import com.ricchieri.filter.BasicFilter;
import com.ricchieri.model.ReservationType;
import com.ricchieri.service.interf.IReservationTypeService;
import com.ricchieri.util.FacesUtil;

@Transactional(readOnly = true)
public class ReservationTypeService implements IReservationTypeService, Serializable {
	private static final long serialVersionUID = 1376645231664107497L;
	
	IReservationTypeDao reservationTypeDao;
	
	@Override
	@Transactional(readOnly = true)
	public List<ReservationType> getAllReservationTypes() {
		BasicFilter filter = new BasicFilter();
		return reservationTypeDao.getAllReservationTypes(filter);
	}

	public IReservationTypeDao getReservationTypeDao() {
		return reservationTypeDao;
	}

	public void setReservationTypeDao(IReservationTypeDao reservationTypeDao) {
		this.reservationTypeDao = reservationTypeDao;
	}

	@Override
	public Map<String, String> getComboReservationType() {
		List<ReservationType> reservationTypeValues = this.getAllReservationTypes();

		Map<String, String> trips = new LinkedHashMap<String, String>();

		for (ReservationType reservationType : reservationTypeValues) {
			trips.put(FacesUtil.getMessage(reservationType.getDescription()), String.valueOf(reservationType.getId()));
		}

		return trips;
	}
	
	@Override
	public ReservationType getReservationTypeById(BasicFilter reservationTypeFilter) {
		return getReservationTypeDao().getReservationTypeById(reservationTypeFilter);
	}
}
